import threading, os
# http://www.devshed.com/c/a/Python/Basic-Threading-in-Python/1/

os.chdir('/home/dms/roque')
theVar = 0 
commands = [ 'python get_readings.py',
             'python send_to_pachube.py',
             'python send_to_last.py',
             'python powermeter_pipeline.py',
             'python command_manager.py',
             'python blink.py',
             ]

commands = [ 'python command_manager.py',
             'python get_pachube_data.py',
             'python send_to_archive.py',
             'python send_to_powermeter.py',
             'python blink.py',
             ]

class MyThread ( threading.Thread ):

   def run ( self ):

      global theVar
      command = commands[theVar]
      theVar = theVar + 1
      print 'starting: ', command
      status = os.system(command)
      print 'os.system(): ', status 

for x in xrange ( len(commands) ):
   MyThread().start()
